#include "../include/Equation.h"

double f1(double x)
{
    //0, PI/2
    return sin(x / 2) - 1;
}

double f2(double x)
{
    //1, 1.4
    return pow(E_, x) - tan(x);
}

double f3(double x)
{
    //0, -0.5
    return pow(x, 3) - 12 * pow(x, 2) + 3 * x + 1;
}

int main()
{
    cout << "(1):" << endl;
    Secant first_solver(f1);
    cout << first_solver.solve(0, PI/2) << endl;
    cout << f1(first_solver.solve(0, PI/2)) << endl;

    cout << endl;
    cout << "(2):" << endl;
    Secant second_solver(f2);
    cout << second_solver.solve(1,1.4) << endl;
    cout << f2(second_solver.solve(1,1.4)) << endl;

    cout << endl;
    cout << "(3):" << endl;
    Secant third_solver(f3);
    cout << third_solver.solve(0, -0.5) << endl;
    cout << f3(third_solver.solve(0, -0.5)) << endl;

    //其它初始值
    cout << endl;
    cout << "Other:" << endl;
    cout << "(1):" << endl;
    cout << first_solver.solve(0, PI/4) << endl;
    cout << f1(first_solver.solve(0, PI/4)) << endl;

    cout << endl;
    cout << "(2):" << endl;
    cout << second_solver.solve(1,1.1) << endl;
    cout << f2(second_solver.solve(1,1.1)) << endl;

    cout << endl;
    cout << "(3):" << endl;
    cout << third_solver.solve(0, -0.1) << endl;
    cout << f3(third_solver.solve(0, -0.1)) << endl;

    return 0;
}